package config;

import interceptor.MyInterceptor;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
import javax.annotation.Resource;

//@Component:通用的注解,将当前类加入容器中
//@Configuration是spring容器的配置类注解,一般和@Bean一起用的

@Configuration  //配置类专用注解
public class InterceptorConfig implements WebMvcConfigurer {//拦截器的配置类，springboot中没有配置文件,需要使用代码的方式将拦截器配置进容器中
    @Resource
    MyInterceptor myInterceptor;
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(myInterceptor).addPathPatterns("/*").excludePathPatterns("/login");
    }

}
